//引入封装好的接口
import {rolelist} from '@/request/api'
//封装一个state接口
interface roleSate {
   rolelist: Array<object>
}

//封装state
const state = {
   rolelist: []
}
//getters
const getters = {
    getMenu(state: roleSate) {
        return state.rolelist
    }
}
//mutations
const mutations = {
    REQ_ROLELIST(state:roleSate,payload:any){
        state.rolelist = payload
    }
}

//行动
const actions = {
    //封装一个行动
    getRoleAction(context:any){
        rolelist()
        .then((res:any)=>{
            console.log(res,'列表');
            if(res.code==200){
                context.commit('REQ_ROLELIST',res.list)
            }
        })
    }
}


//导出封装好的属性
export default {
    state,
    getters,
    mutations,
    actions,
    //开一个命名空间
    namespaced: true
}